/*************************************************************************
	Crytek Source File.
	Copyright (C), Crytek Studios, 2001-2004.
	-------------------------------------------------------------------------
	$Id$
	$DateTime$
	Description: Binding of network functions into script

	-------------------------------------------------------------------------
	History:
	- 24:11:2004   11:30 : Created by Craig Tiller

*************************************************************************/
#ifndef __SCRIPTBIND_NETWORK_H__
#define __SCRIPTBIND_NETWORK_H__

#pragma once

#include <IScriptSystem.h>
#include <ScriptHelpers.h>

class CGameContext;
class CCryAction;

// <title Network>
// Syntax: Network
class CScriptBind_Network :
	public CScriptableBase
{
public:
	CScriptBind_Network( ISystem *pSystem, CCryAction *pFW );
	virtual ~CScriptBind_Network();

	void Release() { delete this; };

	// <title Expose>
	// Syntax: Net.Expose({Class information Table})
	// Arguments: Class information table see example below
	// Description
	//		Exposes class information to the network system like client/server methods and server properties
	//		for serializing data or remote method invocation over the network. If you expose client or server methods
	//      your entity has to include the Client and/or Server tables.
	// Notes:
	// <table>
	//   UNRELIABLE_ORDERED    Unreliable messages are NOT resent if a nack is received\
	//   RELIABLE_ORDERED      Reliable messages are resent if a nack is received 
	//   RELIABLE_UNORDERED    
	//   NO_ATTACH        The RMI is not attached to any data update and thus can't rely on it. Can be used for calls that don't rely on data. It is recommended to prefer NOATTACH RMI's as they are much easier to schedule due to their lower latency.     
	//   PRE_ATTACH       The RMI is attached at the bottom of the data update, so it will be called after the data has been serialized. This can be used to do something with the new data.     
	//   POST_ATTACH      The RMI is attached at the top of the data update for the object. This can be used to prepare the remote entity for incoming new data.       
	//   BOOL       Boolean value e.g: true or false           
	//   FLOAT      Floating Point value (range: 3.4E +/- 38 (7 digits))         
	//   INT8       Signed 8 Bit Integer value (range: -128 to 127)          
	//   INT16      Signed 16 Bit Integer value (range: -32,768 to 32,767)              
	//   INT32      Signed 32 Bit Integer value (range: -2,147,483,648 to 2,147,483,647)            
	//   STRING       String value e.g: "Hello World!"         
	//   STRINGTABLE  Internally the same as a string         
	//   ENTITYID      Entity identifier e.g: g_localActorId 	              
	//   VEC3   3D vector e.g: {x=2.0, y=10.0, z=5.0}               
	// </table>
	// Example:
	//		Net.Expose {
	//			Class = MyClass,
	//			ClientMethods = {
	//				ClSomeClientMethod = { RELIABLE_UNORDERED, POST_ATTACH, ENTITYID },   --RMI method	
	//			},
	//			ServerMethods = {
	//				SvSomeServerMethod = { RELIABLE_ORDERED, PRE_ATTACH, FLOAT },   --RMI method
	//			},
	//			ServerProperties = {
	//				fSomeFloat = FLOAT, --use self.synched.fSomeFloat to serialize or get the serialized value within the script
	//			},
	//		};
	int Expose( IFunctionHandler * pFH );

	// <title DelegateAuthority>
	// Syntax: Net.DelegateAuthority(ScriptHandle ent, int channel)
	// Arguments:
	//		ent		- Entity identifier.
	//		channel - Network channel.
	// Description:
	//    Passes authority for updating an object to some remote channel.
	//    This channel must have had SetServer() called on it at construction time
	int DelegateAuthority( IFunctionHandler * pFH, ScriptHandle ent, int channel );

	virtual void GetMemoryUsage(ICrySizer *pSizer) const
	{
		pSizer->AddObject(this, sizeof(*this));
	}
private:
	void RegisterGlobals();
	void RegisterMethods();

	ISystem        *m_pSystem;
	CCryAction     *m_pFW;
};

#endif
